﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Golf
{
    public class GetSave
    {
        /// <summary>
        /// 根据价格差得到节省多少 返回int {0}%
        /// </summary>
        /// <param name="Pro_MarketPrice">市场价</param>
        /// <param name="Pro_PromotionPrice">促销价</param>
        /// <returns>返回 int类型的节省值</returns>
        public static int _GetSave(decimal Pro_MarketPrice, decimal Pro_PromotionPrice)
        {
            decimal save = (Pro_MarketPrice - Pro_PromotionPrice) / Pro_MarketPrice * 100;//得到 百分比
            //这里进行
            if (save < 100)
            {
                int i = save.ToString().IndexOf('.');
                if (i != -1)
                {
                    //有小数的  进行截取
                    string _save = save.ToString().Substring(0, i);
                    return int.Parse(_save);
                }
                else
                {
                    return Convert.ToInt32(save);
                }
            }
            else
            {
                return 100;
            }
        }
    }
}
